home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / strlib.zip / STRINGS.H < prev    next >
Text File  |  1993-01-04  |  6KB  |  162 lines

  1.  
  2. /*  File   : strings.h
  3.     Author : Richard A. O'Keefe.
  4.     Updated: 1 June 1984
  5.     Purpose: Header file for the "string(3C)" package.
  6.  
  7.     All  the  routines  in  this  package  are  the  original  work   of
  8.     R.A.O'Keefe.   Any  resemblance  between  them  and  any routines in
  9.     licensed software is due entirely  to  these  routines  having  been
  10.     written  using the "man 3 string" UNIX manual page, or in some cases
  11.     the "man 1 sort" manual page as a specification.  See the READ-ME to
  12.     find the conditions under which these routines may be used & copied.
  13. */
  14.  
  15. #ifndef NullS
  16. #define NullS   (char*)0
  17. #define NUL     '\0'
  18.  
  19. /*  MAKE SURE THE RIGHT VERSION OF THE FOLLOWING MACRO IS INSTALLED!  */
  20.  
  21. #if     vax | pdp11 | m68000 | perq
  22. #define CharsAreSigned 1                        /* default is unsigned */
  23. #endif  vax | pdp11 | m68000 | perq
  24.  
  25. #if     CharsAreSigned
  26. #define int2char(i)     (((i)<<((sizeof (int) -1)*8))>>((sizeof (int) -1)*8))
  27. #else  !CharsAreSigned
  28. #define int2char(i)     ((i)&255)
  29. #endif  CharsAreSigned
  30. /*  If characters are signed, but the above doesn't work,
  31.     try ((127-(255&~(i)))^(-128))
  32. */
  33.  
  34. #ifndef _AlphabetSize
  35. #define _AlphabetSize   128
  36. #endif
  37.  
  38. #if     _AlphabetSize == 128
  39. typedef char _char_;
  40. #endif
  41. #if     _AlphabetSize == 256
  42. typedef unsigned char _char_;
  43. #endif
  44.  
  45. /*  NullS is the "nil" character  pointer.   NULL  would  work  in  most
  46.     cases,  but  in  some  C  compilers  pointers and integers may be of
  47.     different sizes, so it is handy to have a nil pointer that  one  can
  48.     pass to a function as well as compare pointers against.
  49.  
  50.     NUL is the ASCII name for the character with code 0.  Its use to end
  51.     strings is a convention of the C programming language.  There are in
  52.     fact three different end of string conventions supported by routines
  53.     in this package:
  54.         str<opn>        : end at the first NUL character
  55.         strn<opn>       : end at the first NUL character, or when the
  56.                           extra "len" parameter runs out.
  57.         mem<opn>,b<opn> : length determined solely by "len" parameter.
  58.     Unfortunately, the VAX hardware only supports the last convention, a
  59.     pity really.  Fortran 77 users BEWARE: Fortran 77's convention is an
  60.     entirely different one, and there are NO routines in this package as
  61.     yet which support it.  (But see section 3F of the 4.2 BSD manual.)
  62.  
  63.     The routines which move characters around don't  care  whether  they
  64.     are  signed or unsigned.  But the routines which compare a character
  65.     in a string with an argument, or use a character from a string as an
  66.     index into an array, do care.  I have assumed that
  67.         _AlphabetSize = 128 => only 0..127 appear in strings
  68.         _AlphabetSize = 256 => only 0..255 appear in strings
  69.     The files _str2set.c and _str2map.c declare character vectors  using
  70.     this  size.  If you don't have unsigned char, your machine may treat
  71.     char as unsigned anyway.
  72.  
  73.     Some string operations (*cmp, *chr) are explicitly defined in various
  74.     UNIX manuals to use "native" comparison, so I have not used _char_ in
  75.     them.  This package is meant to be compatible, not rational!
  76. */
  77.  
  78. extern  char    *strcat(/*char^,char^*/);
  79. extern  char    *strncat(/*char^,char^,int*/);
  80.  
  81. extern  int     strcmp(/*char^,char^*/);
  82. extern  int     strncmp(/*char^,char^,int*/);
  83.  
  84. #define streql  !strcmp
  85. #define strneql !strncmp        /* (str-N)-eql not str-(neq-l)! */
  86.  
  87. extern  char    *strcpy(/*char^,char^*/);
  88. extern  char    *strncpy(/*char^,char^,int*/);
  89.  
  90. extern  int     strlen(/*char^*/);
  91. extern  int     strnlen(/*char^,int*/);
  92.  
  93. extern  char    *strchr(/*char^,_char_*/);
  94. extern  char    *strrchr(/*char^,_char_*/);
  95. #define index   strchr
  96. #define rindex  strrchr
  97.  
  98. extern  char    *strmov(/*char^,char^*/);
  99. extern  char    *strnmov(/*char^,char^,int*/);
  100.  
  101. extern  void    strrev(/*char^,char^*/);
  102. extern  void    strnrev(/*char^,char^,int*/);
  103.  
  104. extern  char    *strend(/*char^*/);
  105. extern  char    *strnend(/*char^*/);
  106.  
  107. extern  char    *strpbrk(/*char^,char^*/);
  108. extern  char    *strcpbrk(/*char^,char^*/);
  109.  
  110. extern  int     strspn(/*char^,char^*/);
  111. extern  int     strcspn(/*char^,char^*/);
  112.  
  113. extern  char    *strtok(/*char^,char^*/);
  114. extern  void    istrtok(/*char^,char^*/);
  115.  
  116. extern  char    *strpack(/*_char_^,_char_^,char^,int*/);
  117. extern  char    *strcpack(/*_char_^,_char_^,char^,int*/);
  118.  
  119. extern  int     strrpt(/*char^,char^,int*/);
  120. extern  int     strnrpt(/*char^,int,char^,int*/);
  121.  
  122. extern  void    strtrans(/*_char_^,_char_^,_char_^,_char_^*/);
  123. extern  void    strntrans(/*_char_^,_char_^,int,_char_^,_char_^*/);
  124.  
  125. extern  char    *strtrim(/*char^,char^,char^,int*/);
  126. extern  char    *strctrim(/*char^,char^,char^,int*/);
  127.  
  128. extern  char    *strfield(/*char^,int,int,int,int*/);
  129. extern  char    *strkey(/*char^,char^,char^,char^*/);
  130.  
  131. extern  char    *strfind(/*char^,char^*/);
  132. extern  char    *strrepl(/*char^,char^,char^,char^*/);
  133.  
  134. extern  void    bcopy(/*char^,char^,int*/);
  135. extern  void    bmove(/*char^,char^,int*/);
  136.  
  137. extern  void    bfill(/*char^,int,char*/);
  138. extern  void    bzero(/*char^,int*/);
  139.  
  140. extern  int     bcmp(/*char^,char^,int*/);
  141. #define beql    !bcmp
  142.  
  143. extern  int     ffs(/*int*/);
  144. extern  int     ffc(/*int*/);
  145.  
  146. extern  char    *substr(/*char^,char^,int,int*/);
  147.  
  148. extern  char    *strxcat(/*VARARGS*/);
  149. extern  char    *strxcpy(/*VARARGS*/);
  150. extern  char    *strxmov(/*VARARGS*/);
  151.  
  152. extern  char    *strxncat(/*VARARGS*/);
  153. extern  char    *strxncpy(/*VARARGS*/);
  154. extern  char    *strxnmov(/*VARARGS*/);
  155.  
  156. #endif  NullS
  157.  
  158. #ifndef memeql
  159. #include "memory.h"
  160. #endif  memeql
  161.  
  162.